# Author:Zhang Yu
class Dog(object):

    def __init__(self,name,food=None):
        self.name = name


    def eat(self,food):
        #print("{0.name!s} eating".format(self))
        print("%s , eating"%self.name,food)
def bulk():
    print("bulk")
if __name__ == '__main__':
    d = Dog("xiaobai")
    choice = input(">> ").strip()
    if hasattr(d,choice):
        func = getattr(d, choice)
        func("baozi")
    else:
        #动态装入方法
        setattr(d,choice,bulk)
        d.talk()
        #删除
        #delattr(d,choice)

    try:
        print("213")
    except KeyError as e:
        print("没有这个Key:",e)
    except Exception:
        print("其他未知错误")
    else:
        print("没有出错的情况")
    finally:
        print("不管有没有出错")